package plugins.system;

import plugins.Plugin;
import main.Main;
import main.Room;
import main.User;

public class RoomsListPlugin extends Plugin {

   @Override
   public void execute(Room room, User user, String command, String text) {
      int i = 1;
      user.dispatch(Main.rooms.size()
            + (Main.rooms.size() == 1 ? " Room" : " Rooms") + " active.");
      for (Room r : Main.rooms) {
         user.dispatch(i + ". " + r.getName() + " (" + r.users.size() + ")");
         i++;
         int j = 1;
         for (User u : r.users) {
            if (u.name != null) {
               user.dispatch("  " + j + ". " + u.name);
            }
            j++;
         }
      }
   }

}
